<template>
  <div class="formList">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="表单名称">
        <el-input size="mini" v-model="formInline.name" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="id">
        <el-input size="mini" v-model="formInline.id" placeholder=""></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <el-card class="box-card">
      <el-table
        v-loading="listLoading"
        :data="formList"
        style="width: 100%">
        <el-table-column
          prop="formName"
          label="表单名称">
        </el-table-column>
        <el-table-column
          prop="id"
          label="id">
        </el-table-column>
        <el-table-column
          label="操作">
          <template slot-scope="scope">
            <el-button @click="view(scope.row)" type="text" size="small">查看</el-button>
            <el-button @click="edit(scope.row)" type="text" size="small">修改</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>

export default {
  name: 'listform',
  data() {
    return {
      formList: [],
      listLoading: false,
      formInline: {name: '', id: ''}
    }
  },
  created() {
    this.getFormList()
  },
  methods: {
    onSubmit() {
      this.getFormList()
    },
    getFormList() {
      this.listLoading = true
      this.$axios.get('/api/form/list').then(res => {
        this.listLoading = false        
        if(res.data.code == 200) {
          this.formList = res.data.data
        }
      }).catch(e => {
        this.$message(e)
        this.listLoading = false        
      })
    },
    view(row) {
      alert('开发中')
    },
    edit(row) {
      this.$router.push({path:'/nuwaform/design/' + row.id})
    }
  }
}
</script>

<style lang="scss" scoped>
.formList {
  padding: 20px;
}
</style>
